package com.xian.zk.controller;

import com.xian.zk.core.DataServerUtil;
import com.xian.zk.core.ServerDataService;
import com.xian.zk.model.Instance;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Set;

/**
 * @program: zoo-task
 * @description:
 * @author: liru.xian
 * @create: 2022-01-14 17:30
 **/
@Slf4j
@RestController
public class ZkController {

    @Autowired
    private ServerDataService serverDataService;
    @RequestMapping("get")
    public List<Instance> getAllServerNode(@RequestParam String serverName){
        return DataServerUtil.getInstancesByServiceName(serverName);
    }

    @RequestMapping("getMap")
    public List<Instance> getMapServerNode(@RequestParam String serviceName){
        return DataServerUtil.getInstancesByServiceName(serviceName);
    }
    @RequestMapping("getPath")
    public Set<String> getPath(){
        return serverDataService.getSerializeId();
    }
    @RequestMapping("getParentPath")
    public String getParentPath(){
        return serverDataService.getParentPath();
    }

}
